/*
 * @lc app=leetcode.cn id=71 lang=javascript
 *
 * [71] 简化路径
 */

// @lc code=start
/**
 * @param {string} path
 * @return {string}
 */
var simplifyPath = function (path) {
    let pathArr = path.split("/")
    let res = []
    for (let p of pathArr) {
        switch (p) {
            case "..":
                res.pop()
                break;
            case "":
                break;
            case ".":
                break;
            default:
                res.push(p)
                break;
        }
    }
    return "/" + res.join("/")
};
// @lc code=end

simplifyPath("/home/")